package com.springmvc.utils.result;

import com.springmvc.netty.command.Command;

public class Result {

	private boolean	success;

	private String	code;

	private String	msg;

	private Command		cammand;

	private Object	data;

	public Result() {
		this.setCode("");
		this.setMsg("");
		this.setSuccess(false);
	}

	public boolean isSuccess() {
		return success;
	}

	public String getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Command getCammand() {
		return cammand;
	}

	public void setCammand(Command cammand) {
		this.cammand = cammand;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Result(boolean success, String code, String msg, Command cammand, Object data) {
		super();
		this.success = success;
		this.code = code;
		this.msg = msg;
		this.cammand = cammand;
		this.data = data;
	}

	public static Result SUCCESS(Command cammand, Object data) {
		Result resultMsg = new Result();
		resultMsg.setSuccess(true);
		resultMsg.setCode("0000");
		resultMsg.setMsg("成功");
		resultMsg.setCammand(cammand);
		resultMsg.setData(data);
		return resultMsg;
	}

	public static Result MSG(Command cammand, String msg) {
		Result resultMsg = new Result();
		resultMsg.setSuccess(true);
		resultMsg.setCode("0000");
		resultMsg.setMsg(msg);
		resultMsg.setCammand(cammand);
		return resultMsg;
	}

	public static Result ERROR(Command cammand, String msg, Object data) {
		Result resultMsg = new Result();
		resultMsg.setSuccess(true);
		resultMsg.setCode("9999");
		resultMsg.setMsg(msg);
		resultMsg.setCammand(cammand);
		resultMsg.setData(data);
		return resultMsg;
	}

	public static Result ERROR(Command cammand, String msg) {
		Result resultMsg = new Result();
		resultMsg.setSuccess(true);
		resultMsg.setCode("9999");
		resultMsg.setMsg(msg);
		resultMsg.setCammand(cammand);
		return resultMsg;
	}

}
